package org.example.fboot.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.fboot.result.Result;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import reactor.core.publisher.Mono;

@Slf4j
@RestController
public class WebController {

    @GetMapping("/test")
    public Mono<Result<String>> test(ServerHttpRequest httpRequest){
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        log.info("info-----");
        return Mono.just(Result.ok());
    }
    @PreAuthorize("isAuthenticated()")
    @GetMapping("/test1")
    public Mono<Result<String>> test1(){
        log.info("test1");
        return Mono.just(Result.ok());
    }

    @GetMapping("/test2")
    public Mono<Result<String>> test2(ServerHttpRequest httpRequest){
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        log.info("info-----");
        return Mono.just(Result.ok());
    }
}
